﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CHPM.PL.DesktopUI.Code.Common;
using CHPM.PL.DesktopUI.Interfaces;
using CHPM.PL.DesktopUI.ServiceReference1;

namespace CHPM.PL.DesktopUI.Presenters
{
    public class MainForm
    {
        private IMainGrid _view;
        private IMainService _mainServiceClient;

        public MainForm(IMainGrid view)
        {
            _view = view;
            _mainServiceClient = IoCContainer.ServiceLocator.Resolve<IMainService>();
            _view.OnGetPatients += SendPatientsToView;
        }

        void SendPatientsToView()
        {
            List<PATIENT> patients = new List<PATIENT>();
            patients = _mainServiceClient.GetAllPatients().ToList();
            _view.SetDataSource(patients);
        }
    }
}
